import React, {Component} from 'react'
import Item from './components/item'
import AddNews from './components/addNews.jsx'
import './news.scss'
import { Button, Modal } from "antd";
export default class News extends Component {
    state = {
        visible: false
    }
    childVm = null
    handleOk = () => {
        const s = this.childVm.getFieldsValue()
        this.setState({ visible: false})
    }
    onChildEventFAun = childVm => {
        this.childVm = childVm
    }
    render() {
        const { visible } = this.state
        return (
            <div className={`news-box`}>
                <Button onClick={() => this.setState({visible: true})} className={`add button`} type="primary" htmlType="submit">
                    添加新闻
                </Button>
                <ul className={`news`}>
                    {
                        [0,0,0,0,0].map((item, idx) => <Item key={idx} />)
                    }
                </ul>
                <Modal
                    title={'添加新闻'}
                    width={`80%`}
                    open={ visible }
                    onOk={ this.handleOk }
                    onCancel={ () => this.setState({ visible: false }) }
                >
                    <AddNews onChildEventFAun={ this.onChildEventFAun } />
                </Modal>
            </div>
        )
    }
}
